<template>
	<view>
		<view class="addr-view">
			<!-- 无地址 新增地址 -->
			<view class="no-addr flex-row-center" @click="addAddr" v-if="!addrInfo">+ 新增收货地址</view>
			<!-- 有地址 -->
			<view class="has-addr flex-row-center" @click="chooseAddr" v-else>
				<view class="addr-left">
					<view class="addr-left-name">
						收件人：{{ $textEllipsis(addrInfo.name, 5) }}
						<text>{{ addrInfo.phone }}</text>
					</view>
					<view style="height: 10rpx;"></view>
					<view class="addr-left-text">{{ addrInfo.province }}{{ addrInfo.city }}{{ addrInfo.region }}{{ addrInfo.address }}</view>
				</view>
				<cmd-icon type="chevron-right" size="16" color="#454545"></cmd-icon>
			</view>
			<image :src="$getImgUrl('home/ic_xian.png')" class="img-line" mode="widthFix"></image>
		</view>

		<view class="goods-view">
			<view class="goods-info flex-row-center">
				<image :src="goods.img" class="img-goods" mode="aspectFill"></image>
				<view class="goods-info-right flex-col">
					<view class="goods-text">{{ goods.name }}</view>
					<view class="guige">{{ goods.specText }}</view>
					<view class="price-view flex-row-between" v-if="payType == 2">
						积分
						<text class="now-price-text">{{ goods.specScore }}</text>
						<view class="goods-num">x{{ goods.num }}</view>
					</view>

					<view class="price-view flex-row-between" v-else>
						<text class="icon-money">¥</text>
						<text class="now-price-text">{{ goods.specPrice }}</text>
						<view class="goods-num">x{{ goods.num }}</view>
					</view>
				</view>
			</view>
		</view>

		<view class="goods-view" style="padding: 0 30rpx;">
			<uni-cell title="运费" value="包邮"></uni-cell>
			<uni-cell title="优惠券" value="请选择" :isLine="false" isLink @click="onCoupon"></uni-cell>
		</view>

		<view style="height: 98rpx;"></view>
		<view class="bottom-view flex-row-center">
			<view class="goods-price-view flex-row-center">
				<text>实付:</text>
				<view class="goods-price flex-row-center" v-if="payType == 2" style="margin-left: 5rpx;">
					积分
					<text>{{ goods.specScore * goods.num }}</text>
				</view>

				<view class="goods-price" v-else>
					￥
					<text>{{ goods.specPrice * goods.num }}</text>
				</view>
			</view>
			<view class="buy-btn" @click="showPay">提交订单</view>
		</view>
		<!-- 支付弹窗 -->
		<uni-popup ref="pay" type="bottom">
			<view class="pay-view">
				<view class="pay-view-title flex-row-center">
					<text>请选择支付方式</text>
					<image src="/static/images/home/ic_gb1.png" class="img-close" mode="widthFix" @click="closePay"></image>
				</view>
				<view class="line"></view>
				<view class="price-view">
					<view class="now-price">
						<text class="shifujine">实付金额：{{ goods.price * goods.num }}</text>
					</view>
				</view>
				<view style="height: 45rpx;"></view>
				<view class="pay-view-item flex-row-center">
					<image :src="$getImgUrl('home/ic_wx.png')" class="img-pay" mode="widthFix"></image>
					<text>微信支付</text>
					<image v-if="payType == 1" :src="$getImgUrl('home/ic_xz.png')" class="img-select" mode="widthFix" @click="payType = 1"></image>
					<image v-else :src="$getImgUrl('home/ic_xz1.png')" class="img-select" mode="widthFix" @click="payType = 1"></image>
				</view>

				<view style="height: 25rpx;"></view>
				<button type="default" class="default-btn" @click="onPayOrder">去付款</button>
			</view>
		</uni-popup>
	</view>
</template>

<script src="./submit.js"></script>

<style lang="scss">
@import '@/style/common.scss';
@import '../shop.scss';
@import './submit.scss';
</style>
